package com.sumainfor.pc.epc.controller.direttore;

import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.epc.service.BuyerAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author PuaChen
 * @Create 2019-01-04 10:21
 * 工程经理审核 备件采购单
 */
@RestController
@RequestMapping("/audit/buyer")
public class BuyerAuditController {

    @Autowired
    private BuyerAuditService auditService;

    /**
     * 备件采购单 的审核操作
     * BuyId 采购单的主编号
     * State 审核状态 采购状态   2采购中 5被驳回（备件）
     * ErrorTitle 驳回类型 1.类型一 2.类型二 3.类型三
     * ErrorMessage   驳回备注
     *
     * @param params
     * @return
     */
    @PostMapping("/auditStockBuyer")
    public JsonResult auditStockBuyer(@RequestBody Map<String, Object> params) {
        if (!FieldCheckUtil.isMapFieldNotNull(params, "BuyId", "State")) {
            return JsonResult.errorForEmpty();
        }
        return auditService.auditStockBuyer(params);
    }

}
